package com.etc.stringdemo;

/**
 * @author: knowno
 * @create: 2024-09-09 15:15
 * @Version 1.0
 * 本质的问题： == 比较的是地址 ,
 **/
public class StringCompare2 {
    public static void main(String[] args) {

        String str = "ILoveJava"; //字面值 =>常量池
        String str1 = "I"; // 字面值 => 常量池
        String str2 = "Love"; //字面值 =》常量池
        String str3 = "Java"; //字面值 =》常量池
        // 变量名 拼接 =>存储在内存堆中
        // 指令集中 ->new Stringbuilder ->append=: I  Love Java
        System.out.println(str == (str1 + str2+str3)); //false

        //"字面值" 拼接 =>存储在常量池
        String str4 = "I" + "Love" + "Java";
        System.out.println(str == str4);// true

    }
}
